package light.head.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;
/**
 * 入库信息表
 */
@Entity
@Table
public class InStock implements Serializable{

	
	private static final long serialVersionUID = -4766310387091965815L;

	
	private Integer code;
	private Integer cu;				// 创建人
	private Date ct;				// 创建时间
	private Integer oc;				//所属机构
	private String remark;			//备注
	private Byte sort;				//类别（1.采购入库2.归还入库3.其他）
	private Integer mc;				//模块编号（归还信息编号）
	private Boolean deleted;
	
	List<InStockItem> itemList;		//入库明细
	
	
	private String cn;
	private String on;
	
	
	
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public String getRemark() {
		return remark;
	}
	@Column
	public Byte getSort() {
		return sort;
	}
	@Column
	public Integer getMc() {
		return mc;
	}
	@Column(length = 8)
	public Integer getOc() {
		return oc;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	
	@Transient
	public List<InStockItem> getItemList() {
		return itemList;
	}	
	
	
	
	
	public void setCode(Integer code) {
		this.code = code;
	}
	
	public void setItemList(List<InStockItem> itemList) {
		this.itemList = itemList;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public void setSort(Byte sort) {
		this.sort = sort;
	}
	public void setMc(Integer mc) {
		this.mc = mc;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
}
